# -*- coding: utf-8 -*-
import requests


class RequestUtil:
    def send_request(self, method, url, params=None, query_params=None, files=None):

        headers = {
            "Content-Type": "application/json"
        }

        if method.upper() == 'GET':
            response = requests.get(url, headers=headers, params=query_params)
        elif method.upper() in ['POST', 'PUT']:
            # 对于POST和PUT请求，将params作为JSON格式的请求体
            if params is not None:
                response = requests.request(method, url, headers=headers, json=params, params=query_params, files=files)
            else:
                response = requests.request(method, url, headers=headers, params=query_params, files=files)
        elif method.upper() == 'DELETE':
            response = requests.delete(url, headers=headers, params=query_params, json=params)
        else:
            raise ValueError(f"Unsupported HTTP method: {method}")
        return response
